package com.stox.resources.i18n;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class MessageSource {

	/**
	 * TODO get resource bundle according to user preferred locale, not default
	 */
	private static final ResourceBundle messages 
	=  ResourceBundle.getBundle("messages", Locale.getDefault());
	private static final MessageFormat messageFormat = new MessageFormat("");
	
	public static String getMessage(String key){
		return messages.getString(key);
	}
	
	public static String getMessage(String key, Object...args){
		messageFormat.applyPattern(getMessage(key));
		return messageFormat.format(args);
	}
	
}
